<template>
    <div>
        <commpVxeTable
        :key="commpVxeTableKey"
        :config="dataTableConfig" 
        :columns="columnsVxe" 
        :selectItem="selectItem"
        :formItem="[]"
        :adaptiveHeight="true"
        @radioChange="radioChange"
        ></commpVxeTable>
    </div>
</template>
<script>
import commpVxeTable from '@/components/commp-vxe-table/commp-vxe-table.vue'
import assessCheckApi from '../service/api'
import {
    spcyRsGcysaveSelectedGcyToSqsx
} from '../service/index'
export default {
    components:{
        commpVxeTable,
    },
    props:{

    },
    data(){
        return{
            commpVxeTableKey:null,
            dataTableConfig:{
                api:assessCheckApi.spcyRsGcyqueryAllJgbm,
                rowId: 'id',
                height:400,
                autoHidden:true,
                pageSize:100,
                paramet:{
                }
            },
            selectItem:{
                selectArr:[],
                key:'id',
            },
            columnsVxe:[{ 
                type: 'radio', 
                width: 60 ,
                fixed: 'left'
            },{
                title: '单位名称', //列头显示文字
                field: 'fdwmc',
            },{
                title: '局长姓名', //列头显示文字
                field: 'fgcyxm',
            },{
                title: '手机号',
                field: 'fphone',
            }],
            currentRow:{},
        }
    },
    watch:{

    },
    mounted(){
        
    },
    methods:{
        getData(val){
            this.currentRow = val
            if(this.dataTableConfig){
                this.dataTableConfig['paramet'] = { sqsxid:val.sqsxid }
            }
            if(val.fcygcyid){
                this.selectItem['selectArr'][0] = val.fcygcyid
            }
            this.commpVxeTableKey = Date.now()
        },
        radioChange({row}){
            spcyRsGcysaveSelectedGcyToSqsx({sqsxid:this.currentRow.sqsxid,id:row.id}).then(res=>{
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.$emit('successChange')
                }else{
                    this.$message.warning(res.message)
                    this.getData(this.currentRow)
                }
            })
        },

    }
}
</script>